home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15286 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: news.cern.ch!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: printing to printer???
  5. Date: 18 Apr 96 09:31:42 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.829819902@news.cern.ch>
  8. References: <829594324.796@smason.demon.co.uk> <4kutku$ggk@cheatum.frontiernet.net> <31755D9C.7775@hlp.com>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=US-ASCII
  12. Content-Transfer-Encoding: 7bit
  13. X-Newsreader: NN version 6.5.0 #18 (NOV)
  14.  
  15. In <31755D9C.7775@hlp.com> andrew kennedy <"andrew kennedy"@hlp.com> writes:
  16.  
  17. >delta4@frontiernet.net wrote:
  18. >> 
  19. >> Jaden@smason.demon.co.uk (Sie) wrote:
  20. >> 
  21. >> >Does anyone know how to print a string to a printer using Ansi C or
  22. >> >Microsoft C++v7????? TIA...
  23.  
  24. ANSI C doesn't define the concept of printer, so any solution is
  25. platform/compiler specific.
  26.  
  27. >> I been wondering the same thing (I use Power C, which is ANSI C
  28. >> compatible).
  29.  
  30. ANSI C compliance is a useless feature as far as this topic is concerned.
  31. See above.
  32.  
  33. > /* Filename: printit.cpp     Written by A. Kennedy */
  34. >              // Send output directly to printer
  35.  
  36. You must have forgotten that you were posting to c.l.c :-)
  37. This is the only possible explanation for your syntax errors.
  38.  
  39. > #include <stdio.h>
  40. > #include <stdlib.h>
  41.  
  42. What do you need <stdlib.h> for?
  43.  
  44. > #include <conio.h>
  45.  
  46. This is both compiler specific and not needed here.
  47.  
  48. > FILE *prnt;
  49. >
  50. > void main()
  51.   ^^^^
  52. You also forgot to read the FAQ of the newsgroup before posting.
  53.  
  54. > {
  55. >    prnt = fopen("PRN", "w");   /* LTP1 would also work */
  56.                                     ^^^^
  57.                             I beg to disagree :-)
  58.  
  59. >    fprintf(prnt, "     This output was sent to the printer.");
  60.  
  61. It will work much better with a newline appended.  Otherwise, the user
  62. will have to play with the printer buttons or the next program will
  63. print on the same line, which is usually less than desirable.
  64.  
  65. >    fclose(prnt);
  66. > }
  67.  
  68. Dan
  69. --
  70. Dan Pop
  71. CERN, CN Division
  72. Email: danpop@mail.cern.ch 
  73. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  74.